package kr.co.sdworld.api.apns.repository.tokensample;

import java.util.List;

import kr.co.sdworld.api.apns.model.ApnsTokenSample;
import kr.co.sdworld.api.apns.model.ApnsTokenSampleExample;
import kr.co.sdworld.api.apns.model.mapper.ApnsTokenSampleMapper;
import kr.co.sdworld.common.util.generator.IDGenerator;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

@Repository
public class ApnsTokenSampleDaoImpl extends SqlSessionDaoSupport implements ApnsTokenSampleDao
{
	@Override
	public int create(ApnsTokenSample sample) {
		ApnsTokenSampleMapper mapper = getSqlSession().getMapper(ApnsTokenSampleMapper.class);
		sample.setObjId(IDGenerator.generate());
		int result = mapper.insertSelective(sample);
		return result;
	}
	
	public List<ApnsTokenSample> search(String appId, String userId)
	{
		ApnsTokenSampleMapper mapper = getSqlSession().getMapper(ApnsTokenSampleMapper.class);
		ApnsTokenSampleExample exam = new ApnsTokenSampleExample();
		exam.createCriteria().andAppIdEqualTo( appId).andUserIdEqualTo( userId);
		return mapper.selectByExample(exam);
	}
}
